/*
 * @Author: your name
 * @Date: 2020-12-31 16:09:27
 */
import Vue from 'vue';
import VueRouter from 'vue-router';
if (process.env.NODE_ENV === 'development') {
  //开发环境不使用cdn
  Vue.use(VueRouter);
}

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

//----------------------demo#router-----------------------

const Demo_Routes = [{
    path: '/',
    component: () => import('@/demo/home/index.vue'),
    name: "首页",
    hidden: true,
  },
  {
    path: '/flv-player-demo',
    name: "播放页flv",
    component: () => import('@/demo/video/FlvPlayerDemo.vue'),
    hidden: true,
  },
];


//----------------------demo#router-----------------------



// 定义默认路由
export const DefaultRoutes = [{
    path: '/login',
    name: "登录",
    component: () => import('@/pages/Login.vue'),
    hidden: true,
  },
  {
    path: '/404',
    name: "异常页",
    component: () => import('@/pages/404.vue'),
    hidden: true,
  },
].concat(Demo_Routes);
// 动态路由配置，也可以在服务端存储
// component的路径配置[@/demo/dashboard/index.vue]=>[demo/dashboard/index]
export const DynamicRoutesMap = [{
    path: '/demo',
    component: 'layout/index',
    redirect: '/demo/dashboard',
    children: [{
      path: 'dashboard',
      component: 'demo/dashboard/index',
      meta: {
        title: '控制台',
        icon: 'dashboard',
        activeMenu: '/demo/dashboard'
      }
    }]
  },
  {
    path: '/user',
    component: 'layout/index',
    redirect: '/user/table',
    meta: {
      title: '用户管理',
      icon: 'el-icon-s-help',
    },
    children: [{
        path: 'table',
        component: 'demo/Test2',
        meta: {
          title: '表格',
          icon: 'table',
        }
      },
      {
        path: 'other',
        component: 'pages/404',
        meta: {
          title: '其他',
          icon: 'el-icon-s-help',
          roles: ['user', 'admin']
        },
      }
    ]
  },
  {
    path: '/map',
    component: 'layout/index',
    redirect: '/map/show',
    meta: {
      title: '地图管理',
      icon: 'el-icon-s-help',
    },
    children: [{
        path: 'show',
        component: 'demo/amap/index',
        meta: {
          title: '地图创建',
          icon: 'table',
        }
      },
      {
        path: 'other',
        component: 'pages/404',
        meta: {
          title: '其他',
          icon: 'el-icon-s-help',
          roles: ['user', 'admin']
        },
      }
    ]
  },
  // 当使用通配符路由时，请确保路由的顺序是正确的，也就是说含有通配符的路由应该放在最后。路由 { path: '*' } 通常用于客户端 404 错误
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]
//初始化vue-router实例
const router = new VueRouter({
  routes: DefaultRoutes,
  mode: 'history'
});
export default router;